#pragma once

#include "defines.h"
#include "Context.h"
#include "Helpers/Timer.h"
#include "Objects/Object.h"
#include "Graphics/SpriteAnimationManager.h"
#include "Components/Graphics/SpritesheetComponent.h"

enum TileType
{
	LEFT,
	TOP,
	RIGHT,
	BOTTOM,
	TOPLEFT,
	TOPRIGHT,
	BOTTOMLEFT,
	BOTTOMRIGHT,
	NOBORDER,
	NORMAL
};

enum TileColor
{
	BLACKTILE,
	WHITETILE
};

const int ROWS = 10;
const int COLOMS = 12;
const int WHITEOFFSET = 6;
const int BLACKOFFSET = 0;

class BaseTile : public star::Object
{
public:
	BaseTile(TileType type,TileColor color, ivec2 position);
	~BaseTile() {}

	TileType GetType(){return m_Type;}
	void	 SetType(TileType type);
	
	void	  SetColor(TileColor color);
	TileColor GetColor(){return m_TileColor;}

	vec2	 GetPosition();
	void	 SetPosition(ivec2 position);
	
	void	 SetSwitchTime(float time);
	float	 GetSwitchTime(){return m_SwitchTime;}

	void	SetTileID(int8 id) {m_SquareID = id;};
	int8	GetTileID() const {return m_SquareID;}

protected:
	void Initialize();
	void AfterInitialzed();
	void Update(const star::Context& context);

private:
	static bool m_bTexturesLoaded;
	void LoadAllTextures();
	void SetTypeColor(TileType type,TileColor color);

	TileType m_Type;
	TileColor m_TileColor;
	ivec2 m_Position;
	int8 m_SquareID;

	star::SpritesheetComponent* m_SpriteTile;

	float m_SwitchTime,m_ElpasedTime;
	bool m_bInitialized;

	BaseTile(const BaseTile&);
	BaseTile(BaseTile&&);
	BaseTile& operator=(const BaseTile&);
};
